package com.aliyun.oss.mapper;

import com.aliyun.oss.pojo.ArticleContent;
import com.aliyun.oss.pojo.ArticleInfo;
import com.aliyun.oss.pojo.ArticleListParams;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleManage {
    List<ArticleInfo> getArticleList(@Param("id") Integer userId,@Param("pageBegin")Integer pageBegin,@Param("articleListParams") ArticleListParams articleListParams);

    @Select("SELECT count(*) FROM article_manage WHERE article_manage.user_id=#{userId}")
    Integer getAllArticleList(Integer userId);
    @Insert("INSERT INTO `article_manage` ( user_id, title, cate_id, content, cover_img,pub_date,state) VALUES ( #{userId}, #{title}, #{cateId}, #{content}, #{imgUrl},#{pubDate},#{state});")
    void addArticle(ArticleContent articleContent);
    @Select("SELECT id,user_id,title,state,pub_date,cover_img imgUrl,content,cate_id FROM article_manage WHERE id = #{id} AND user_id = #{userId}")
    ArticleContent getArticleInfo(Integer userId, Integer id);

    @Update("UPDATE article_manage SET title = #{title},cate_id = #{cateId},content = #{content},cover_img = #{imgUrl} WHERE id = #{id} AND user_id = #{userId};")
    void updateArticleInfo(ArticleContent articleContent);
}
